#include "timeout.h"

void* core::timeout_doit(void *timeout) 
{
	core::timeout *t = (core::timeout*) timeout;
	t->_f();
}

core::timeout::timeout(const boost::function0<void> &f, int sek)
: _f(f), _sek(sek)
{
	pthread_t thrd;
	pthread_create(&thrd, NULL, core::timeout_doit, (void*)this);
	sleep(_sek);
	pthread_detach(thrd);
	pthread_cancel(thrd);
	pthread_join(thrd, NULL);
}

